<?php

declare(strict_types=1);

namespace magein\laravel\seecms\middleware;

use Closure;
use Illuminate\Http\Request;
use magein\seecms\library\Auth;
use magein\seecms\library\View;

/**
 * 判断是否登录中间件
 */
class AuthorizationMiddleware
{
    public function handle(Request $request, Closure $next)
    {
        $info = Auth::user()->info();

        if (empty($info)) {
            return response(View::fetch('user/no.login')->data);
        }

        return $next($request);
    }
}
